<template>
	<view class="page">
		<u-navbar title="我的小区" border @leftClick="$utils.back()" placeholder />
		<view class="body">
			<z-paging  ref="paging" style="height: 100%;" :fixed="false" v-model="data" @query="query"
				:default-page-no="1" :default-page-size="10">
				<template v-if="!loading">
					<view v-for="item in data" :key="item.id" class="userItem" >
						<image class="image" :src="item.district.cover" mode="aspectFill"></image>
						<view class="flex">
							<view>
								<u-text :text='item.district.name' :lines='1' size='30rpx' />
							</view>
							<view>
								<u-icon name='account' size='28rpx' :label='item.district.user_count' labelSize='24rpx'/>
							</view>
						</view>
					</view>
				</template>
				<template v-else>
					<view v-for="item in 10" :key="item" class="userItem">
						<view class="image Skeleton"></view>
						<view class="flex">
							<view style="height: 40rpx;" class="Skeleton"></view>
							<view style="height: 30rpx;" class="Skeleton"></view>
						</view>
					</view>
				</template>
			</z-paging>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				loading: true,
			}
		},
		methods: {
			query(page, size) {
				let obj = {
					page,
					size
				}
				uni.showLoading({
					title: '加载中...'
				})
				this.$api.My.District(obj).then(res => {
					uni.hideLoading()
					this.$refs.paging.complete(res.data.data)
					this.loading = false
				}).catch(err => {
					uni.hideLoading()
					uni.$u.toast(err.data.message)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0rpx 20rpx;
		height: 100vh;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 10rpx);
		/* 兼容 iOS 设备 */
		padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx);
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
	}

	.body {
		flex: 1;
		overflow: hidden;
	}

	.userItem {
		display: flex;
		margin: 20rpx 0 0 0;
		position: relative;

		.image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 8rpx;
			margin-right: 20rpx;
		}

		.flex {
			height: 100rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding-bottom: 10rpx;
			box-sizing: border-box;
			border-bottom: 1rpx solid #eee;
			flex: 1;

		}
	}


</style>